<template>
  <div class="compitem">
    <div class="compname">{{title}}</div>
    <!-- <el-input style="width:200px;" v-model="value"></el-input> -->
    <div class="filewarp" style="width:200px;">
       <el-upload
   :action="$src+'/api/upload'"
              name="file"
              class="upload-demo"
              :file-list="filelist"
              :multiple="false"
              :limit="1"
              :on-success="successfile"
              :on-remove="remove"
  >
  <el-button size="small" type="primary">点击上传</el-button>
</el-upload>
    </div>
   
  </div>
</template>
<script>
export default {
  props:{
   title:{
     type:String
   },
   name:{
     type:String
   },
   val:{
     type:String
   },

  },
  data() {
    return {
      value:'',
      filelist:[],
    }
  },
  created() {
    // this.value=this.val
    if(this.val){
      console.log(val)
      this.filelist.push({name:'附件',url:this.val+''})
    }
    
    this.$emit('func',{name:this.name,val:this.val})
  },
  methods: {
    successfile(res){
    console.log(res)
    if(res.code==200){
      this.$emit('func',{name:this.name,val:res.data.path})
    }
    },
    remove(){
       this.$emit('func',{name:this.name,val:''})
    }
  },
  watch: {
    value:function(params) {
      // console.log(this)
      this.$emit('func',{name:this.name,val:this.value})
    }
  },
}
</script>
<style lang="scss" scoped>
.compitem{
  .compname{
    font-size: 14px;
    // width: 90px;
    // padding: 0 15px;
    // padding-right:15px;
    width: 90px;


  }
  width: 100%;
  display: flex;
   align-items: center;
}
</style>